from PySide2.QtWidgets import QFileDialog


class File_Select_Tools:
    """
    文件选择工具类
    """

    @staticmethod
    def select_one_file(parent=None, title="Select one file", fileter_type="csv file(*.csv)"):
        """
        选择单文件
        :param parent:
        :param title:
        :param fileter_type:
        :return: 返回元组，一个为文件路径，第二个文件类型
        """
        fileName = QFileDialog.getOpenFileName(parent=parent,
                                               caption=title,
                                               dir=None,
                                               filter=fileter_type,
                                               # options=QFileDialog.DontUseNativeDialog
                                               )
        return fileName

    @staticmethod
    def select_dir(parent=None, title="Select one dir"):
        """
        获取用户选择的文件夹路径
        :param parent:
        :param title: 标题
        :return: 文件夹路径
        """
        dir_path = QFileDialog.getExistingDirectory(parent=parent, caption=title, options=QFileDialog.ShowDirsOnly
                                                                            | QFileDialog.DontResolveSymlinks)
        return dir_path
